home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Original Shareware 1.1
/
The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso
/
38
/
sgn_bans.zip
/
SIGNSMIF.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-12-17
|
12KB
|
402 lines
{ Program SignSmif.Pas "Sign-Smith" }
{ Prints signs, overhead masters, and fancy title pages }
{ Needs Font1.dat, Font2.dat, Font3.dat, Font4.dat }
{ The program EditFont.Pas allows modification of these fonts. }
{ In the compiler options, A = 4000, i.e.
{ 4000 (hex segs) appears to be a suitable max heap size for .COM file }
{$I StringOf.Pas } { generates strings of repeated chars. }
{$I Parse2.Pas } { string parser }
{$I Replacec.Pas } { replace one char by another in string }
{$I Trim.Pas } { trims trailing blanks from strings }
{$I Environm.Pas } { searches environment for wanted item }
{$I PrintPak.Pas } { include printer procedures & globals }
Const
NumberOfOptions = 4 ;
Var
ch : char ;
fname : string[30] ;
keystr : string[6] ;
datafile : text ;
tempstr : CardImage ; { type defined in Parse2 }
SubStr : StrArray ; { type defined in Parse2 }
SubSubStr : StrArray ;
nsubs, nsubsubs : integer ;
j,jj,k,mm,n,err : integer ;
DotRows, DotCols, xloc, yloc, YlocExtra : integer ;
Between, Font : integer ;
centre, FirstLine, OffPage, BadFile, FirstTime : boolean ;
tb : byte ;
label ByPassScan, CleanUpAndExit, MoreFiles ;
Procedure HandleOneLine(PrePass : Boolean) ;
{
This procedure, internal to main, handles one line of data.
If PrePass is true, merely checks that data line fits on screen.
If PrePass is false, does screen display &/or print.
In Prepass, returns OffPage, a variable in main program
}
begin
OffPage := false ;
readln(datafile,tempstr) ;
if FirstLine then { landscape declaration must at start of file }
begin
LandScape := (tempstr[1] = '\') and (upcase(tempstr[2]) = 'L') ;
FirstLine := false ; { never check this again }
end ;
if tempstr[1] = '\' then
begin
Tempstr[1] := ' ' ;
ReplaceChar(TempStr,',',' ') ; { replace comma by space }
j := 0 ; { = parse all }
Parse2(TempStr,SubStr,nsubs,j) ;
for j := 1 to nsubs do
begin
ReplaceChar(SubStr[j],'=',' ') ; { replace = by space }
k := 2 ;
Parse2(Substr[j],SubSubStr,nsubsubs,k) ;
ch := Copy(SubSubStr[1],1,1) ;
ch := Upcase(ch) ;
if ch = 'C' then
begin
if Copy(SubSubStr[1],2,1) = '-'
then centre := false
else centre := true ;
end { ch = 'C' }
else
if ch in ['D','F','K','R','S','X','Y'] then
begin { should be a numeric argument ... }
Val(SubSubStr[2],n,err) ;
if err <> 0 then
begin
writeln('Error in ',SubSubStr[2],' within ...') ;
Writeln(SubStr[j],' within ...') ;
Writeln(TempStr) ;
Halt ;
end
else
begin
case ch of
'D' : YlocExtra := n ; { Down }
'F' : if n in [1..NumberOfFonts] then
begin
Font := n ;
if PrePass then WantFont[n] := true ;
end ;
'K' : DotCols := n ; { ColSize }
'R' : DotRows := n ; { RowSize }
'S' : Between := n ; { extra separation between chars }
'X' : Xloc := n ;
'Y' : Yloc := n ;
end ; { case }
end { else from err <> 0 }
end ; { get numeric argument }
end ; { for j }
end { if line starts with \ }
else { no leading \ , so this line must be text for printing }
begin
j := Trim(TempStr) ; { remove trailing blanks, to avoid mis-centre }
PutString(TempStr,xloc,yloc,Font,DotCols,DotRows,Between,
Centre,PrePass,OffPage) ;
Yloc := Yloc + YlocExtra ; { add any extra vertical space }
end ;
end ; { HandleOneLine }
begin { *** MAIN PROGRAM *** }
FirstTime := true ;
CheckTextOnly := false ;
ClrScr ;
gotoxy(1,5) ;
TextColor(LightGray) ;
TextBackground(black) ;
Write('SignSmif the ') ;
TextColor(Black) ;
TextBackground(LightGray) ;
write('"Sign-Smith"') ;
TextColor(LightGray) ;
TextBackground(Black) ;
writeln(' Version 1.11') ;
writeln ;
writeln('Copyright (C) by Bryan B. Smith, Kingston, Ont., 1985') ;
writeln ;
writeln('All Rights Reserved.') ;
{ Version 1.11, about 1/5 reduction in time to create printer bit map by
{ putting "change" code in printpak in-line, 1/4 in screen draw time. }
writeln ;
writeln('This program may be copied and distributed on a ',
'non-profit basis.') ;
writeln ;
delay(1500) ;
MoreFiles : { in "C" mode, program loops back to here }
{ If user gave us a file name, check it out before loading fonts ...}
if (ParamCount > 0) and FirstTime then { If file name was on command line }
begin
fname := ParamStr(1) ;
{ add default extension if needed ... }
if pos('.',fname) = 0 then fname := fname + '.sgn' ;
assign(datafile,fname) ;
{$I-}
reset(datafile) ;
{$I+}
j := IOresult ;
if j <> 0 then
begin
write('File ',fname,' not found.') ;
halt ;
{
end
else
begin
}
end ;
end { if (ParamCount }
else
begin { no file name on command line }
write('Enter name of your') ;
repeat
writeln(' data file or enter Q to quit ') ;
write('The default extension is .sgn ') ;
readln(fname) ;
if (length(fname) = 1) and (upcase(fname[1])='Q') then halt ;
if pos('.',fname) = 0 then fname := fname + '.sgn' ;
assign(datafile,fname) ;
{$I-}
reset(datafile) ;
{$I+}
j := IOresult ;
if j <> 0 then write('File not found. Re-enter name of') ;
until j = 0 ;
end ;
FirstTime := false ;
if ParamCount > 1 then
begin
KeyStr := ParamStr(2) ;
end { if ParamCount }
else { option not on command line }
if not CheckTextOnly then
begin
ClrScr ;
writeln ;
writeln('Your Options now are ...') ;
writeln ;
writeln(' P to printout.') ;
writeln(' S to show on screen.') ;
writeln(' N for No-grid.') ;
writeln(' F to do fast screen-show of first letters only, no print.') ;
writeln(' C for text check only - no screen display, no print.') ;
writeln ;
write('Enter codes for your choice, e.g. SPN, or <return> for SP ') ;
readln(KeyStr) ;
end ; { else }
if length(KeyStr) = 0 then KeyStr := 'SP' ;
WantScreen := false ;
WantPrint := false ;
FirstCharOnly := false ;
CheckTextOnly := false ;
grid := true ;
for j := 1 to length(KeyStr) do
begin
ch := upcase(KeyStr[j]) ;
case ch of
'S' : WantScreen := true ;
'P' : WantPrint := true ;
'N' : grid := false ;
'C' : begin { C over-rides all other specs. }
WantScreen := false ;
WantPrint := false ;
CheckTextOnly := true ;
goto ByPassScan ;
end ; { 'C' }
'F' : begin { F over-rides all other specs. }
WantScreen := true ;
WantPrint := false ;
FirstCharOnly := true ;
grid := true ;
goto ByPassScan ;
end ; { 'F' }
end ; { case }
end ; { for j }
ByPassScan :
{ start pre-check of file ... }
for j := 1 to NumberOfFonts do WantFont[j] := false ;
centre := false ; { set default values ... }
Xloc := 1 ; { user's x & y start at 1, programs at 0 }
Yloc := 100 ;
Font := 2 ;
DotCols := 4 ;
DotRows := 2 ;
YlocExtra := 0 ;
Between := 0 ;
BadFile := false ;
FirstLine := true ;
while not EOF(datafile) do
begin
HandleOneLine(true) ; { internal procedure : PrePass is True } ;
BadFile := BadFile or OffPage ; { update BadFile }
end ; { while not EOF }
if CheckTextOnly
then
begin
writeln ;
write('End of checkout of file ') ;
TextColor(White) ;
writeln(fname) ;
TextColor(LightGray) ;
writeln('If no error messages were printed, this file will ',
'fit on the page.') ;
writeln('You may continue with the checkout of another file.') ;
writeln ;
goto MoreFiles ; { warning - backwards jump }
end
else
begin
If Badfile then
begin
writeln ;
writeln('Due to above errors, will not do screen and/or printing.') ;
writeln ;
halt ;
end ; { if Bad }
end ; { else }
reset(datafile) ;
Init_PrintPak ;
writeln ;
writeln('Please remember ...') ;
writeln ;
{ ' Press any LETTER key to STOP program.' }
{ 1234 1234 }
{ 123456789012345678901234 123456789 }
write(' Press any LETTER key to ') ;
textcolor(white) ;
write('STOP') ;
textcolor(LightGray) ;
writeln(' program.') ;
write('':4,StringOf(24,#196)) ; { #196 = horizontal single line }
textcolor(white+Blink) ;
write(stringof(4,#196)) ;
textcolor(LightGray) ;
writeln(Stringof(9,#196)) ;
delay(2000) ;
if WantScreen then
begin
HiRes; HiResColor(7) ; { draw in 640- * 200- dot mode }
if grid then DrawGrid ;
end ;
centre := false ; { set default values ... }
Xloc := 1 ; { user's x & y start at 1, programs at 0 }
Yloc := 100 ;
Font := 2 ;
DotCols := 4 ;
DotRows := 2 ;
YlocExtra := 0 ;
Between := 0 ;
FirstLine := true ;
while not EOF(datafile) do
begin
HandleOneLine(false) ; { internal procedure, & not a Pre-Pass }
end ; { while not EOF }
if not WantScreen then ClrScr ; { get rid of text (but not graphics) }
if not WantPrint then { it's time to quit }
begin
gotoxy(1,1) ;
write('Press any letter to exit. ') ;
repeat until keypressed ;
read(KBD,ch) ;
Goto CleanUpAndExit ;
end ;
if WantPrint and (not WantScreen) and (ParamCount > 2) then
{ user wants print only, and specified left margin on command line }
begin
Val(ParamStr(3),leftmarg,j) ;
end
else { ask user for left margin }
begin
repeat
gotoxy(52,1) ; { clear space for ans }
write('':3) ;
gotoxy(1,1) ;
write('Print or Quit (grid dots don''t print) ? (p or q) ') ;
{ 12345678901234567890123456789 01234567890123456789012 }
readln(ch) ;
ch := UpCase(ch) ;
until ch in ['P','Q'] ;
if ch = 'Q' then goto CleanUpAndExit ;
repeat
gotoxy(1,1) ;
writeln('Enter extra left margin width, spaces. Usual is 7 ') ;
gotoxy(19,2) ;
write('':2) ;
gotoxy(1,2) ;
write('O.K. to enter 0 ') ;
{ 1234567890123456789 }
{$I-}
readln(leftmarg) ;
{$I+}
until IOresult = 0 ;
end ; { ask user }
Printout ;
{ Print-it-again section - bypass if left margin was in command line }
if ParamCount <= 2 then { no user-specified left margin on command line }
begin
repeat
repeat
gotoxy(1,1) ;
writeln('Enter new left margin to re-print with a ',
'different left margin') ;
gotoxy(23,2) ;
write('':2) ;
gotoxy(1,2) ;
write('or enter -1 to quit. ') ;
{ 1234567890123456789012 }
{$I-}
readln(LeftMarg) ;
{$I+}
until IOresult = 0 ;
if LeftMarg >= 0 then
begin
gotoxy(1,1) ;
writeln('Press space bar when printer ready.','':27) ;
write('':75) ;
repeat until keypressed ;
Read(KBD,ch) ;
Printout ;
end ; { if LeftMarg }
until LeftMarg < 0 ;
end ; { if ParamCount }
CleanUpAndExit :
TextMode(BW80) ;
ClrScr ;
end .